package com.example.cpl.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

public class View1 extends AppCompatActivity {

    private Button but_1,but_2,but_3,but_4,btn_s;
    private ImageButton but_Data;

    private void initWidght()
    {
        but_Data= (ImageButton) findViewById(R.id.but_Data);
        but_1=(Button)findViewById(R.id.but_1);
        but_2=(Button)findViewById(R.id.but_2);
        but_3=(Button)findViewById(R.id.but_3);
        but_4=(Button)findViewById(R.id.but_4);
        btn_s=(Button)findViewById(R.id.btn_s);
    }

    private void change_image()         //切换头像
    {
        switch(MainActivity.who)
        {
            case 1: but_Data.setImageDrawable(getResources().getDrawable(R.drawable.who1)); //设置按钮图片（对应头像）
                break;
            case 2: but_Data.setImageDrawable(getResources().getDrawable(R.drawable.who2)); //设置按钮图片（对应头像）
                break;
            case 3: but_Data.setImageDrawable(getResources().getDrawable(R.drawable.who3)); //设置按钮图片（对应头像）
                break;
            default:

                break;
        }

    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view1);
        initWidght();
        change_image();//切换头像
        but_Data.setScaleType(ImageView.ScaleType.CENTER_INSIDE);//图片设置大小 居中显示

        but_Data.setOnClickListener(new View.OnClickListener() {            //有头像的按钮
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,View2.class);
                startActivity(intent);
            }
        });
        but_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,View3.class);     //跳转界面 同下
                startActivity(intent);
            }
        });
        but_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,View4.class);
                startActivity(intent);
            }
        });
        but_3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,View5.class);
                startActivity(intent);
            }
        });
        but_4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,View6.class);
                startActivity(intent);
            }
        });
        btn_s.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(View1.this,connect_server.class);
                startActivity(intent);
            }
        });





    }
}
